#pragma once

///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		12/01/2014												 //
//	Purpose:	Define a shape that represents a 3D box					 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "IBoundingShape.h"
#include "Vectors.h"

// represents a 6-sided 3 dimensional shape
struct BoundingBox : public IBoundingShape
{
	// the position of the center of the box
	Vector3 position;

	// the distance the front z-coordinate is from 'position'
	float front;
	// the distance the back z-coordinate is from 'position'
	float back;
	// the distance the left x-coordinate is from 'position'
	float left;
	// the distance the right x-coordinate is from 'position'
	float right;
	// the distance the top y-coordinate is from 'position'
	float top;
	// the distance the bottom y-coordinate is from 'position'
	float bottom;

	// Creates a new instance of BoundingBox
	BoundingBox(void);
	// Creates a new instance of BoundingBox
	BoundingBox(Vector3& position, float size);
	// Creates a new instance of BoundingBox
	BoundingBox(Vector3& position, float front, float back, float left, float right, float top, float bottom);

	// returns true if the box intersects the provided shape
	virtual bool Intersects(IBoundingShape* other) override;

	// gets the type of bounding shape this is
	virtual BoundingShapeType getType(void) const override;

	// computes the x-coodinate of the left side of the box from 'position' in world space
	float getWorldLeft(void) const { return position.x - left; }
	// computes the x-coodinate of the right side of the box from 'position' in world space
	float getWorldRight(void) const { return position.x + left; }
	// computes the y-coodinate of the top side of the box from 'position' in world space
	float getWorldTop(void) const { return position.y - top; }
	// computes the y-coodinate of the bottom side of the box from 'position' in world space
	float getWorldBottom(void) const { return position.y + bottom; }
	// computes the z-coodinate of the front side of the box from 'position' in world space
	float getWorldFront(void) const { return position.z - front; }
	// computes the z-coodinate of the back side of the box from 'position' in world space
	float getWorldBack(void) const { return position.z + back; }

	// computes the width of the box
	float computeWidth(void) const { return getWorldRight() - getWorldLeft(); }
	// computes the height of the box
	float computeHeight(void) const { return getWorldBottom() - getWorldTop(); }
	// computes the depth of the box
	float computeDepth(void) const { return getWorldBack() - getWorldFront(); }
};